﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using OMS.OMSService;

namespace OMS.Models
{
    public class OrderItemModelView
    {
        public OrderItemModelView() { }

        public OrderItemModelView(OrderItemModel orderItem)
        {
            Id = orderItem.Id;
            Price = orderItem.Price;
            Quantity = orderItem.Quantity;
            Item = orderItem.ItemModel;
            ItemId = orderItem.ItemModel.Id;
            Dimension = orderItem.Dimension;
        }

        public OrderItemModel ToOrderItemModel()
        {
            OrderItemModel orderItemModel = new OrderItemModel
            {
                Id = this.Id,
                Price = this.Price,
                Quantity = this.Quantity,
                ItemModel = this.Item,
                ItemId = ItemId,
                Dimension = this.Dimension
            };
            return orderItemModel;
        }

        public int Id { get; set; }

        [Required]
        [Display(Name = "Price")]
        public decimal Price { get; set; }

        [Required]
        [Display(Name = "Quantity")]
        public int Quantity { get; set; }

        public ItemModel Item { get; set; }

        public int ItemId { get; set; }

        public string Dimension { get; set; }
    }
}